package com.zhangfuyin.controller;


import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * ① 继承Controller类 通过配置文件如下配置具体的Handler
 *    <bean name="/welcom.do" class="com.zhangfuyin.controller.Controller1"/>
 *
 *
 */
public class Controller1 implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        ModelAndView mv = new ModelAndView();

        /**
         * 这里代码比较冗余  如何解决呢？
         * ①通过注册视图解析器方式 配置如下
         *       <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
         *         <property name="prefix" value="/WEB-INF/"/>
         *         <property name="suffix" value=".jsp"/>
         *       </bean>
         *
         *
         *
         */
        //mv.setViewName("/WEB-INF/welcome.jsp");
        mv.setViewName("welcome");
        return mv;
    }
}
